package cn.edu.bjtu.core;

import org.deeplearning4j.eval.Evaluation;
import org.deeplearning4j.nn.api.Layer;
import org.deeplearning4j.nn.graph.ComputationGraph;
import org.deeplearning4j.optimize.api.IterationListener;
import org.deeplearning4j.util.ModelSerializer;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;


/**
 * Created by alex on 17/6/16.
 */
class SparkComputationGraph implements NeuronNetwork{
    ComputationGraph cg;

    @Override
    public void load() throws Exception {
        cg = ModelSerializer.restoreComputationGraph(this.getClass().getResourceAsStream(SparkConfiguration.CNN_MODEL), true);
    }

    @Override
    public Layer[] getLayers() {
        return cg.getLayers();
    }
    @Override
    public Deep4jModelType getActualType() {
        return Deep4jModelType.ComputationGraph;
    }
    @Override
    public void init() {
        throw new RuntimeException("Not Support");
    }
    public INDArray[] output(INDArray... input) {
        return cg.output(input);
    }
    public void fit(DataSetIterator iterator) {
        throw new RuntimeException("Not Support");
    }
    @Override
    public Evaluation evaluate(DataSetIterator iterator) {
        throw new RuntimeException("Not Support");
    }
    @Override
    public void saveModel(String path) throws Exception {
        throw new RuntimeException("Not Support");
    }

    @Override
    public void setListeners(IterationListener... listeners) {
        throw new RuntimeException("Not Support");
    }
}
